package javamem;

import java.io.FileInputStream;
import java.util.Properties;

public class Config {

    private static Config instance;
    private Properties properties = new Properties();

    private Config() {
        try {
            FileInputStream fin = new FileInputStream("./config.properties");
            properties.load(fin);
            fin.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static Config getInstance() {
        if(instance == null) {
            instance = new Config();
        }
        return instance;
    }

    public String getString(String key) {
        return properties.getProperty(key);
    }

    public int getInt(String key) {
        return Integer.parseInt(properties.getProperty(key));
    }

    public double getDouble(String key) {
        return Double.parseDouble(properties.getProperty(key));
    }

}
